package Thread;

public class Demo3 {

    public static void main(String[] args)throws InterruptedException{
        Thread t1=new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("hello Thread");
                try{
                    Thread.sleep(1000);
                }catch(InterruptedException e){
                    e.printStackTrace();
                    break;
                }
            }
        });
        t1.start();
        Thread.sleep(3000);
       t1.interrupt();
    }
}
